package com.fastwire.carriere.inventory.vo;

import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.Root;

import com.fastwire.carriere.common.mapper.TPNameMapper;
import com.fastwire.carriere.common.util.StringUtil;
import com.fastwire.carriere.dao.DAOException;
import com.fastwire.carriere.dao.DAOFactory;
import com.fastwire.carriere.dao.NetworkInventoryDao;
import com.fastwire.carriere.inventory.entity.FDFr;
import com.fastwire.carriere.inventory.entity.NetworkEntityUserSpecificInfo;
import com.fastwire.carriere.inventory.entity.TopologicalLink;

// TODO: Auto-generated Javadoc
/**
 * The Class TopologicalLinkVo.
 */
@Root(name = "TopologicalLink")
public class TopologicalLinkVo {

	/** The oid. */
	private long oid;

	/** The native ems name. */
	@Attribute
	private String nativeEmsName;

	/** The name. */
	@Attribute
	private String name;

	/** The aend tp. */
	@Attribute(required = false)
	private String aendTp;

	/** The zend tp. */
	@Attribute(required = false)
	private String zendTp;

	/** The direction. */
	@Attribute(required = false)
	private String direction;

	/** The layer rate. */
	@Attribute(required = false)
	private String layerRate;

	/** The type. */
	@Attribute(required = false)
	private String tlType;

	/** The length. */
	@Attribute(required = false)
	private String length;

	/** The wane. */
	@Attribute(required = false)
	private String wane;
	@Attribute(required = false)
	private String remarks;
	@Attribute(required = true)
	private String type = "TopologicalLink";

	/**
	 * Instantiates a new topological link vo.
	 */
	public TopologicalLinkVo() {
		super();
	}

	/**
	 * Instantiates a new topological link vo.
	 * 
	 * @param tl
	 *            the tl
	 */
	public TopologicalLinkVo(TopologicalLink tl) {
		super();
		this.oid = tl.getOid();
		this.nativeEmsName = tl.getEmsNativeName();
		this.name = tl.getName();

		try {
			if (tl.getAendTp() != null) {
				aendTp = TPNameMapper.getReadableTpName(tl.getAendTp()
						.getName(), tl.getAendTp().getType(), null);
			}

			if (tl.getZendTp() != null) {
				zendTp = TPNameMapper.getReadableTpName(tl.getZendTp()
						.getName(), tl.getZendTp().getType(), null);
			}

			this.direction = tl.getDirection();
			this.layerRate = tl.getLayerRate();
			this.tlType = tl.getType();
			this.length = tl.getLength();
			this.wane = tl.getWane();

			if (!StringUtil.isEmptyString(nativeEmsName)) {

				NetworkInventoryDao inventoryDao = DAOFactory.getInstance()
						.getNetworkInventoryDao();
				NetworkEntityUserSpecificInfo info = inventoryDao
						.getNetworkEntityUserSpecificInfobyNameAndType(
								nativeEmsName, FDFr.class.getSimpleName());
				if (info != null) {
					remarks = info.getRemark();
				}
			}
		} catch (DAOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	/**
	 * Gets the oid.
	 * 
	 * @return the oid
	 */
	public long getOid() {
		return oid;
	}

	/**
	 * Sets the oid.
	 * 
	 * @param oid
	 *            the new oid
	 */
	public void setOid(long oid) {
		this.oid = oid;
	}

	/**
	 * Gets the native ems name.
	 * 
	 * @return the native ems name
	 */
	public String getNativeEmsName() {
		return nativeEmsName;
	}

	/**
	 * Sets the native ems name.
	 * 
	 * @param nativeEmsName
	 *            the new native ems name
	 */
	public void setNativeEmsName(String nativeEmsName) {
		this.nativeEmsName = nativeEmsName;
	}

	/**
	 * Gets the name.
	 * 
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * Sets the name.
	 * 
	 * @param name
	 *            the new name
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * Gets the aend tp.
	 * 
	 * @return the aend tp
	 */
	public String getAendTp() {
		return aendTp;
	}

	/**
	 * Sets the aend tp.
	 * 
	 * @param aendTp
	 *            the new aend tp
	 */
	public void setAendTp(String aendTp) {
		this.aendTp = aendTp;
	}

	/**
	 * Gets the zend tp.
	 * 
	 * @return the zend tp
	 */
	public String getZendTp() {
		return zendTp;
	}

	/**
	 * Sets the zend tp.
	 * 
	 * @param zendTp
	 *            the new zend tp
	 */
	public void setZendTp(String zendTp) {
		this.zendTp = zendTp;
	}

	/**
	 * Gets the direction.
	 * 
	 * @return the direction
	 */
	public String getDirection() {
		return direction;
	}

	/**
	 * Sets the direction.
	 * 
	 * @param direction
	 *            the new direction
	 */
	public void setDirection(String direction) {
		this.direction = direction;
	}

	/**
	 * Gets the layer rate.
	 * 
	 * @return the layer rate
	 */
	public String getLayerRate() {
		return layerRate;
	}

	/**
	 * Sets the layer rate.
	 * 
	 * @param layerRate
	 *            the new layer rate
	 */
	public void setLayerRate(String layerRate) {
		this.layerRate = layerRate;
	}

	/**
	 * Gets the type.
	 * 
	 * @return the type
	 */
	public String getType() {
		return type;
	}

	/**
	 * Sets the type.
	 * 
	 * @param type
	 *            the new type
	 */
	public void setType(String type) {
		this.type = type;
	}

	/**
	 * Gets the length.
	 * 
	 * @return the length
	 */
	public String getLength() {
		return length;
	}

	/**
	 * Sets the length.
	 * 
	 * @param length
	 *            the new length
	 */
	public void setLength(String length) {
		this.length = length;
	}

	/**
	 * Gets the wane.
	 * 
	 * @return the wane
	 */
	public String getWane() {
		return wane;
	}

	/**
	 * Sets the wane.
	 * 
	 * @param wane
	 *            the new wane
	 */
	public void setWane(String wane) {
		this.wane = wane;
	}

	public String getRemarks() {
		return remarks;
	}

	public void setRemarks(String remarks) {
		this.remarks = remarks;
	}

	public String getTlType() {
		return tlType;
	}

	public void setTlType(String tlType) {
		this.tlType = tlType;
	}

}
